package com.sl.au.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.E2R;
import com.sl.au.entity.M2R;
import com.sl.au.entity.Module;
import com.sl.au.entity.Role;
import com.sl.au.repository.AccountRepository;
import com.sl.au.repository.E2RRepository;
import com.sl.au.repository.M2RRepository;
import com.sl.au.repository.ModuleRepository;
import com.sl.au.repository.RoleRepository;
import com.sl.au.service.E2RService;
import com.sl.au.service.M2RService;
@Service("E2RService")
@Transactional
public class E2RServiceImpl extends BaseServiceImpl implements E2RService {

	@Autowired
	E2RRepository e2rRepository;
	
	public E2RRepository getRepository(){
		return this.e2rRepository;
	}

	@Override
	public List<E2R> getEventTypes(int start, int length, Role role, String orderName, String dir){
		Page<E2R> pages = null;
		Pageable pageable=new PageRequest(start/length,length, Sort.Direction.ASC,"eventType.eventOrder");
		pages = e2rRepository.findByRole(role, pageable);
		return pages.getContent();
	}
 
}
